[pallet-revive] do not trap the caller on instantiations with duplicate contracts#7414
[pallet-revive] do not trap the caller on instantiations with duplicate contracts#7414
Conversation
…tion Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
|
/cmd prdoc --audience runtime_dev --bump major |
|
Nice catch. Thank you. I am wondering: The catch blocks of Solidty do also apply to reverts where some data is returned. Do we need to encode some error data here, too? |
|
Good point. There should be no need for us to encode anything, because the |
|
You are right we are good here. AFAIK the EVM never encodes anything into the return buffer. That is completely controlled by the callee contract. So for every error in a subcall that is not a revert the Especially |
…te contracts (#7414) This PR changes the behavior of `instantiate` when the resulting contract address already exists (because the caller tried to instantiate the same contract with the same salt multiple times): Instead of trapping the caller, return an error code. Solidity allows `catch`ing this, which doesn't work if we are trapping the caller. For example, the change makes the following snippet work: ```Solidity try new Foo{salt: hex"00"}() returns (Foo) { // Instantiation was successful (contract address was free and constructor did not revert) } catch { // This branch is expected to be taken if the instantiation failed because of a duplicate salt } ``` `revive` PR: paritytech/revive#188 --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This PR changes the behavior of
instantiatewhen the resulting contract address already exists (because the caller tried to instantiate the same contract with the same salt multiple times): Instead of trapping the caller, return an error code.Solidity allows
catching this, which doesn't work if we are trapping the caller. For example, the change makes the following snippet work:revivePR: paritytech/revive#188